package com.factory.iamp.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TemporaryTableMapper {
    @Update("DROP TEMPORARY TABLE if exists select_list")
    void dropIdListForQuery();

    @Update("CREATE TEMPORARY TABLE select_list(id int, orderid int auto_increment key)")
    void idListForQuery();

    @Insert({
            "<script>",
            "insert into select_list(id) values ",
            "<foreach collection = 'BodyList' item = 'item' index = 'index' separator = ','>",
            "(#{item})",
            "</foreach>",
            "</script>"
    })
    void addIdList(@Param("BodyList") List<Integer> BodyList);
}
